import { request } from "../utils/request";
import {
  allCommodity,
  commodityDetail,
} from "./__mock__/commodity";
import { ALL, TREND } from "../asserts/CommodityType";


//发起商品请求
export const getCommodity = ({ type = 1 }) => {
  // return request(`${URL_PREFIX}/commodity?type=${type}`);
  switch (type) {
    case ALL:
      return Promise.resolve(allCommodity);
    default:
      return Promise.resolve([]);
  }
};

//发起商品请求
export const getCommodity2 = ({ type = 1 }) => {
  // return request(`${URL_PREFIX}/commodity?type=${type}`);
  switch (type) {
    case ALL:
      return Promise.resolve(allCommodity);
  }
};

//获取商品信息
function getGoods(){
  my.request({
    url: `${URL}/app-api/chl/app/goods`,
    data: {
      type: 1
    },
    headers:{"tenant-id":"1"},
    success: (result) => {
      if (!result.data.success) {
        console.log(result.data)
      }
    },
    fail: (err) => {
      console.Log({
        ...err,
        message: '获取商品信息异常'
      });
    }
  });
}

export const getCommodityDetail = id => {
  return Promise.resolve(commodityDetail);
};
